const rules = require('./webpack.rules');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
const assets = ['assets'];


rules.push({
  test: /\.css$/,
  use: [{ loader: 'style-loader' }, { loader: 'css-loader' }],
});
rules.push({
  test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  use: {
    loader: "url-loader",
    options: {
      limit: 20 * 1024, // 20Kb
      outputPath: "/",
      publicPath: "/src/assets/",
      name: "[path][name].[ext]",
      esModule: false,
    },
  },
});
var copyPlugins = new CopyWebpackPlugin(
  {
    patterns: assets.map((asset) => ({
      from: path.resolve(__dirname, 'src', asset),
      to: path.resolve(__dirname, '.webpack/main', asset)
    }))
  }
);
module.exports = {
  // Put your normal webpack config below here
  module: {
    rules,
  },
  plugins: [
    copyPlugins
  ]
};
